package com.wu;

import java.util.ArrayList;
import java.util.List;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * @description: <br>
 * @date: 2020/6/15 <br>
 * @author: fei.wu <br>
 */

@Getter
@Setter
@NoArgsConstructor
public class Pipeline {

    List<Rule> list = new ArrayList<>();

    Integer price;

    public Pipeline(Integer price) {
        this.price = price;
    }

    public void addValve(Rule rule) {
        list.add(rule);
    }

    public Integer invoke() {
        Context context = new Context(list.iterator(),price);
        return context.invokeNext(price);
    }
}
